package com.liu.fresh.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liu.fresh.biz.IAddrInfoBiz;
import com.liu.fresh.entity.AddrInfo;
import com.liu.fresh.mapper.IAddrInfoMapper;
import com.liu.fresh.util.StringUtil;




@Service
public class AddrInfoBizImpl implements IAddrInfoBiz {
	@Autowired
	private IAddrInfoMapper mapper;

	@Override
	public Integer add(String mno, String name, String tel, String province, String city, String area, String addr, String flag) {		
		if(StringUtil.checkNull(mno ,name, tel, province, city, area, addr, flag)){
			return 0;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		map.put("name", name);
		map.put("tel", tel);
		map.put("province", province);
		map.put("city", city);
		map.put("area", area);
		map.put("addr", addr);
		map.put("flag", flag);
		return mapper.add(map);
	}

	@Override
	public List<AddrInfo> finds(String mno) {
		if(StringUtil.checkNull(mno)){
			return null;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);		
		return mapper.finds(map);
	}

	@Override
	public int setFlag(String ano,int flag) {
		if(StringUtil.checkNull(ano)){
			ano="1";
		}
		if(StringUtil.checkNull(ano,flag)){
			return 0;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("ano", ano);		
		map.put("flag", flag);		
		return mapper.setFlag(map);
	}

	
}
